package com.lanxin.oa.fiancial.dao;

import com.lanxin.base.BaseDaoImpl;
import com.lanxin.bean.BxInformaltype;
import com.lanxin.util.PageBean;
import org.springframework.stereotype.Repository;

@Repository
public class ExpenseDaoImpl extends BaseDaoImpl implements ExpenseDao {

    @Override
    public PageBean<BxInformaltype> selectBxInfoPage(Integer page, Integer pageSize) {
        if (page==null){
            page = 1;
        }
        if(pageSize == null){
            pageSize = 5;
        }
        String hql=("from BxInformaltype");
        return super.pageFenYE(hql, page, pageSize);
    }

    @Override
    public BxInformaltype selectByBxInfoName(String name, Integer oid) {
        String hql = "from BxInformaltype b where b.name='" + name + "' ";
        BxInformaltype bxInformaltype = null;
        if (oid != null) {
            hql = hql + " and b.oid=" + oid;
            bxInformaltype = (BxInformaltype) selectByHQL(hql);
            if (bxInformaltype != null) {
                return null;
            }
            bxInformaltype = (BxInformaltype) selectByHQL("from BxInformaltype b where  b.name='" + name + "' ");
            if (bxInformaltype == null) {
                return null;
            }
        } else {
            return (BxInformaltype) selectByHQL(hql);
        }

        return bxInformaltype;
    }

    @Override
    public BxInformaltype selectBxInFor(Integer oid) {
        return (BxInformaltype) selectByHQL("from BxInformaltype b where b.oid="+oid);
    }
}
